<?php

declare (strict_types=1);
/**
 * @copyright 深圳市易果网络科技有限公司
 * @version 1.0.0
 * @link https://dayiguo.com
 */

namespace App\Controller\user;

use App\Dao\GoodsDao;
use App\Dao\UserDao;
use App\Kernel\Util\UserJwtInstance;
use App\Middleware\User\UserMiddleware;


use App\Service\User\UserService;
use Hyperf\Di\Annotation\Inject;
use Hyperf\HttpServer\Annotation\AutoController;
use Hyperf\HttpServer\Annotation\Middleware;

/**
 * 积分控制器
 *
 * @AutoController()
 * @Middleware(UserMiddleware::class)
 * @author 张昊(2396675557@qq.com)
 * @package App\Controller\admin
 */
class ScoreController extends Controller
{
    /**
     * 用户服务
     *
     * @Inject
     * @var UserService
     */
    private $service;

    /**
     * 用户 Dao
     *
     * @Inject
     * @var UserDao
     */
    private $dao;

    /**
     * 商品 Dao
     *
     * @Inject
     * @var GoodsDao
     */
    private $GoodsDao;

    /*
     * 获取用户积分
     */
    public function getUserIntegral() {
        $user = UserJwtInstance::instance()->build()->getUser();

        $this->success($user->integral);
    }

    /**
     * 查询积分商品
     */
    public function getIntegralGoods() {
        $map = [
            'buy_type' => 1,
            'is_marketable' => 1,
            'disable' => 1,
        ];
        $result = $this->GoodsDao->get($map);

        $this->success($result);
    }
}